\section{Contextual Analysis}
	\label{section:ContextualAnalysis}
	
	Once the AST has been generated, we invoke the \textit{contextual analyzer}. The contextual analyzer, also sometimes referred to as the \textit{visitor} due to its following the visitor design pattern\cite{gof}.
	
	The contextual analyzer traverses the entire AST in two passes, decorating each node with relevant information such as expression types, references to objects pointed to by identifiers, and actual code that is to be executed on runtime. 
	
	In the first pass, it adds definitions and declarations to the \textit{scope dictionaries}\footnote{Dictionaries mapping identifier strings to their corresponding objects, with added support for traversing parent scopes to search for a specific identifier.}, calculates the types of all expressions, sets node parents and performs other miscellaneous decorations depending on the type of node it is visiting.
	
	In the second pass, type checking is performed. For instance, the expressions passed to an action as parameters are checked against the expected parameter types of the action. During this pass, code generation is performed as well, effectively decorating every single CLUBs statement node with the code that is to be performed by that statement. These smaller bits of code are then padded onto the block nodes to facilitate easy execution of a block of CLUBs code at runtime.
	
	\lstset{language=[Sharp]C}
	\begin{lstlisting}[caption={Visitor padding block with statement code.}]
foreach (StatementNode stmt in block.Statements)
{
	// Visit the statement
	stmt.Visit(this);
	// Add the statement's translated method to the block's translated method
	block.TranslatedMethod += stmt.TranslatedMethod;
}
	\end{lstlisting}
	